Passed
Push — master ( f9579a...f98097 )
by Eric
44s
created

inherits.js ➔ ... ➔ module.exports   B

Complexity

Conditions 6
Paths 1

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 6
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 22
rs 8.6737
1
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.inherits = f()}})(function(){var define,module,exports;module={exports:(exports={})};
3 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable define seems to be never declared. If this is a global, consider adding a /** global: define */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Unused Code introduced by
The variable define seems to be never used. Consider removing it.
Loading history...
2
/*!
3
 * inherits.js | v0.2.0 | Easily inherit prototypes.
4
 * Copyright (c) 2017 Eric Zieger (MIT license)
5
 * https://github.com/theZieger/inherits.js/blob/master/LICENSE
6
 *
7
 * inherit the prototype of the SuperConstructor
8
 *
9
 * Warning: Changing the prototype of an object is, by the nature of how
10
 * modern JavaScript engines optimize property accesses, a very slow
11
 * operation, in every browser and JavaScript engine. So instead of using
12
 * Object.setPrototypeOf or messing with __proto__, we create a new object
13
 * with the desired prototype using Object.create().
14
 *
15
 * @see https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf
16
 *
17
 * @param {Object} Constructor
18
 * @param {Object} SuperConstructor
19
 *
20
 * @throws {TypeError} if arguments are `null`, `undefined`, or
21
 *                     `SuperConstructor` has no prototype
22
 *
23
 * @returns {Void}
24
 */
25
module.exports = function(Constructor, SuperConstructor) {
26
  if (Constructor === undefined || Constructor === null) {
27
    throw new TypeError('Constructor argument is undefined or null');
28
  }
29
30
  if (SuperConstructor === undefined || SuperConstructor === null) {
31
    throw new TypeError('SuperConstructor argument is undefined or null');
32
  }
33
34
  if (SuperConstructor.prototype === undefined) {
35
    throw new TypeError('SuperConstructor.prototype is undefined');
36
  }
37
38
  /**
39
   * for convenience, `SuperConstructor` will be accessible through the
40
   * `Constructor.super_` property
41
   */
42
  Constructor.super_ = SuperConstructor;
43
44
  Constructor.prototype = Object.create(SuperConstructor.prototype);
45
  Constructor.prototype.constructor = Constructor;
46
};
47
48
return module.exports;});
49